package team.future.joke.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import team.future.joke.entity.Joke;
import team.future.joke.service.JokeReceiveService;
import team.future.joke.service.JokeService;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * Title: JokeReceiveServiceImpl.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月18日 下午5:29:29 <br>
 * @author futurezhu
*/
@Service("jokeReceiveService")
public class JokeReceiveServiceImpl implements JokeReceiveService {

	@Autowired
	private JokeService jokeService;
	@Override
	public void syncData(JSONArray syncDatas) {
		for (int i = 0; i < syncDatas.size(); i++) {
			JSONObject data = syncDatas.getJSONObject(i);
			Joke joke = new Joke();
			joke.setId(data.getString("id"));
			joke.setNid(data.getIntValue("nid"));
			joke.setStatus(data.getString("status"));
			joke.setTitle(data.getString("title"));
			joke.setContent(data.getString("content"));
			joke.setType(data.getString("type"));
			joke.setTime(new Date());
			jokeService.insertJoke(joke);
		}
	}

}
